<template>
    <v-system-bar window id="titlebar" app style="user-select: none;" data-tauri-drag-region>
        <v-icon class="me-2" icon="mdi-apps" data-tauri-drag-region></v-icon>
        <slot data-tauri-drag-region name="titleText">v-system-bar text</slot>
        <v-spacer></v-spacer>
        <v-btn size="small" id="titlebar-minimize" icon="mdi-window-minimize" variant="text"></v-btn>
        <v-btn size="small" id="titlebar-maximize" icon="mdi-window-maximize" variant="text"></v-btn>
        <v-btn size="small" id="titlebar-close" icon="mdi-window-close" variant="text"></v-btn>
    </v-system-bar>
</template>
<script setup>
import { getCurrentWindow } from '@tauri-apps/api/window';

document.addEventListener('DOMContentLoaded', (event) => {
    const appWindow = getCurrentWindow();

    // 获取所有需要特殊处理的元素
    const minimizeButton = document.getElementById('titlebar-minimize');
    const maximizeButton = document.getElementById('titlebar-maximize');
    const closeButton = document.getElementById('titlebar-close');

    minimizeButton?.addEventListener('click', () => {
        console.log(123);
        appWindow.minimize();
    });

    maximizeButton?.addEventListener('click', () => {
        appWindow.toggleMaximize();
    });

    closeButton?.addEventListener('click', () => {
        appWindow.close();
    });
});
</script> 